import { http } from '@/utils/http';

const baseURL = import.meta.env.VITE_HTTP_BASE_URL;

export const uploadFile = (tempFilePath : string) => {
	// const authStore = useAuthStore();
	// const token = authStore.profile?.access_token;
	const token = ''
	return new Promise((resolve, reject) => {
		uni.uploadFile({
			url: `${baseURL}/wx/file/upload`,
			filePath: tempFilePath,
			name: "file",
			header: {
				'Authorization': `Bearer ${token}`,
			},
			success: (result) => {
				resolve(JSON.parse(result.data));
			},
			fail: (error) => {
				console.log('error', error);
				reject(error);
			}
		})
	})
}

/**
 * 1=隐私政策条款|2=许可证|3=服务条款|4=积分兑换规则
 */
export const getDoc = (docType : 1 | 2 | 3 | 4) => {
	return http<AnyObject>({
		method: 'GET',
		url: `/wx/doc/${docType}`
	});
}

export const getHotline = () => {
	return http<string>({
		method: 'GET',
		url: `/wx/doc/hotline`
	});
}